var redis = require('redis');
var redisClient = redis.createClient(6379, '127.0.0.1');


module.exports = {
    setRedis: function setRedis(key, field, value, callback) {
        redisClient.hmset(key, field, value, function (err, data) {
            return callback(err, data);
        });
    },
    getRedis: function getRedis(key, field, callback) {
        redisClient.hmget(key, field, function (err, data) {
            callback(err, data);
        })
    },
    getRedisLen: function getRedisLen(key, callback) {
        redisClient.hlen(key, function (err, data) {
            callback(err, data);
        })
    },
    delRedis: function delRedis(key, field, callback) {
        redisClient.hdel(key, field, function (err, data) {
            callback(err, data);
        })
    },
    setExpire: function setExpire(key, value){
        redisClient.expire(key,3600);
    }
};